package com.one.common.view.dialog.binder;

import androidx.annotation.NonNull;

import com.one.common.R;
import com.one.common.view.dialog.item.DialogListItem;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;

/**
 * Author: zhulunjun
 * Email: zhulunjun@qq.com
 * CreateDate: 2018/11/16 11:00
 * Description：列表弹窗适配器
 **/
public class DialogListBinder extends BaseItemBinder<DialogListItem> {
    private ItemClickListener itemClickListener;
    public DialogListBinder(ItemClickListener itemClickListener) {
        super(R.layout.item_dialog_list);
        this.itemClickListener = itemClickListener;
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull DialogListItem item) {
        holder.setText(R.id.tv_btn, item.getName());
        holder.getView(R.id.tv_btn).setOnClickListener(v -> {
            if(itemClickListener != null){
                itemClickListener.onClick(item, holder.getAdapterPosition());
            }
        });
    }


    public interface ItemClickListener{
        void onClick(DialogListItem item, int position);
    }
}
